<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="my" uri="/my-tags" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'bookSearch.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet" type="text/css" href="images/main.css">
<link rel="stylesheet" type="text/css" href="images/pagingExt.css">


<script type="text/javascript" src="images/jquery.js"></script>
<script type="text/javascript">
$(function(){
	$("#submit").click(function(){
		//alert($("#wd").val().length);return false;
		if ($("#wd").val().replace(/\ +/g,"")==""){
			$("#wd").focus();
			alert("请输入检索词!");
			return false;
		}else if ($("#wd").val().length>10){
			$("#error").html("检索词不能超过50个字符!");
			return false;
		}else{
			$("#searchBox").submit();
		}
	});
	
	$("#bookType").change(function(){
		$("#bt").val($("#bookType").val());
		$.ajax({
			type:"get",
			url:"search",
			data:$("#searchBox").serialize()
		});
	});
	$("#bookDep").change(function(){
		$("#bd").val($("#bookDep").val());
		$("#searchBox").submit();
	});
	
	$("#bookType").val($("#bt").val());
	$("#bookDep").val($("#bd").val());
	
	
	$("tr").mouseleave(function(){
		$(this).css("background-color","#fefefe");
		$("thead tr").css("background-color","#F3F8F7");
	});
	$("tr").mouseover(function(){
		$(this).css("background-color","#E9E9E4");
		$("thead tr").css("background-color","#F3F8F7");
	});

});
</script>
</head>

<body>
	<div class="mainBox">
	<div style="padding:20px">
			<form action="search" method="get" id="searchBox">
				<input type="hidden" value="search" name="op" />
				<s:textfield type="hidden" name="bt" theme="simple"/>
				<s:textfield type="hidden" name="bd" theme="simple"/>
				<s:set value="#{0:'全文',1:'索书号',2:'条码号',3:'ISBN',4:'期刊号',5:'标题',6:'作者',7:'出版社' }" var="sts"/>
				<s:select list="sts" name="st" theme="simple"></s:select>
				<s:textfield name="wd" theme="simple" id="wd" cssClass="text"/> <input type="submit"
					value="Search" class="buttons" id="submit" />
			</form>
	</div>
			<div id="error"></div>
		<s:if test="#session.SESSION_SEARCH_RESULTS != null">
		<script type="text/javascript">
		$("#searchBox").css("margin-top", "0");
		$("#searchBox").css("margin", "0");
		</script>
 		<s:set var="datat" value="#{0:'图书',1:'光盘',2:'期刊'}"/>
    	<table class="table_list" cellpadding="3" cellspacing="1" border="0">
    	<thead><tr style="background:#F3F8F7"><td>序号</td><td>条码号/期刊号</td><td>藏馆类型</td><td>典藏地</td><td>索书号/期刊类型</td><td>题名</td><td>责任人</td><td>出版者</td><td>出版年份/期数</td><td>单价/年价</td><td>ISBN</td><td>在库数量</td><td colspan="3" width="80px">操作</td></tr></thead>

    	<s:iterator value="#session.SESSION_SEARCH_RESULTS" var="each" status="st">
    		<tr style="background:#fefefe">
    		<td><s:property value="#st.index + 1"/></td>
    		<td><s:property value="#each.bookBarCode"/><s:property value="#each.periNo"/></td>
    		<td><s:property value="#datat[#each.dataType]"/></td>
    		<td><s:property value="#each.bookCollection"/></td>
    		<td><s:property value="#each.bookCallNo"/><s:property value="#each.periType"/></td>
    		<td><a href="queryBook?op=info&id=<s:property value="#each.bookId"/>" title="查看本书详情">
    		<s:if test="#each.bookName.length()>=15">
    		<s:property value="#each.bookName.substring(0,14)"/>...
    		</s:if>
    		<s:else>
    		<s:property value="#each.bookName"/>
    		</s:else>
    		</a></td>
    		<td><s:if test="#each.bookChargePerson.length()>=15">
    		<s:property value="#each.bookChargePerson.substring(0,14)"/>...
    		</s:if>
    		<s:else>
    		<s:property value="#each.bookChargePerson"/>
    		</s:else>
			</td>
    		<td><s:property value="#each.bookPublishing"/></td>
    		<td><s:property value="#each.bookPublishingTime"/><s:property value="#each.perPeriods"/></td>
    		<td><s:property value="#each.bookPrice"/></td>
    		<td><a href="http://book.douban.com/isbn/<s:property value="#each.ISBN"/>" target="_blank" title="去豆瓣查看本书介绍"><s:property value="#each.ISBN"/></a></td>
    		<td><s:property value="#each.bookCount"/></td>
    		<td><a href="queryBook?op=detail&id=<s:property value="#each.bookId"/>">修改</a></td>
    		
    		<s:if test="#each.bookCount<1">
    		<td><a href="#" style="color:#ccc">借阅</a></td>
    		</s:if><s:elseif test="#each.bookCount>=1">
    		<td><a onclick="window.open ('borrowBook?bid=<s:property value="#each.bookId"/>&uid=', '请选择借阅用户', 'height=100px, width=600px, scrollbars=no, resizable=no')">借阅</a></td>
    		</s:elseif><s:else>
    		<td> </td>
    		</s:else>
    		
    		<td><a onclick="if (confirm('操作不可恢复，确认删除?'))$.ajax({type:'post',url:'delBook',data:{id:<s:property value="#each.bookId"/>},success : function(data){alert(data);location.reload();}});">删除</a></td>
    		</tr>
    	</s:iterator>
    	
    		<tr style="background:#fefefe"><td colspan="99" align="right">
<my:page pageSize="${sessionScope.SESSION_SEARCH_PAGESIZE }"
							pageNo="${sessionScope.SESSION_SEARCH_PAGENO }" url="search"
							count="${sessionScope.SESSION_SEARCH_COUNT }" op="search"
							wd="${sessionScope.SESSION_WD }" st="${sessionScope.SESSION_ST }"></my:page>
					</td></tr>
    	</table>
		</s:if>

	</div>
</body>
</html>
